package com.jungle.design.mode.state;

import com.jungle.design.mode.common.IBaseEnum;
import com.jungle.design.mode.state.dto.OrderDTO;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author Jungle
 * @create 2023-12-09 9:53
 * 状态模式只适用于单项的转换
 */

@Getter
@AllArgsConstructor
public enum OrderStateEnum implements OrderState, IBaseEnum<String> {
    UNPAY("unpay", "未支付") {
        @Override
        public void nextState(OrderDTO order) {
            order.setState(PAIED);
        }
    }, PAIED("paied", "已支付") {
        @Override
        public void nextState(OrderDTO order) {
            order.setState(FINISHED);
        }
    }, FINISHED("finished", "已经完成") {
        @Override
        public void nextState(OrderDTO order) {
            //    结束了这里不做逻辑

        }
    };
    private final String value;
    private final String label;


}
